﻿CREATE PROCEDURE [dbo].[Purchase_PaymentProcess_Put]
	@purchaseId bigint,

	@paymentProcessStatus nvarchar(50) = NULL,
	@paymentProcessError nvarchar(32) = NULL,
	@paymentProcessErrorInfo nvarchar(MAX) = NULL,
	@paymentProcessPaymentId nvarchar(MAX) = NULL,
	@paymentProcessInvoiceId nvarchar(MAX) = NULL,
	@paymentProcessPayer nvarchar(MAX) = NULL,
	@paymentProcessPayee nvarchar(MAX) = NULL,
	@paymentProcessCreditAmount decimal(8,2) = NULL,

	@purchaseStatusId SMALLINT = NULL
AS
BEGIN
	UPDATE [dbo].[purchase_Item]
	SET [PaymentProcessDate] = GETUTCDATE()
			,[PaymentProcessStatus] = @paymentProcessStatus
			,[PaymentProcessError] = @paymentProcessError
			,[PaymentProcessErrorInfo] = @paymentProcessErrorInfo
			,[PaymentProcessPaymentId] = @paymentProcessPaymentId
			,[PaymentProcessInvoiceId] = @paymentProcessInvoiceId
			,[PaymentProcessPayer] = @paymentProcessPayer
			,[PaymentProcessPayee] = @paymentProcessPayee
			,[PaymentProcessCreditAmount] = @paymentProcessCreditAmount

			,[PurchaseStatusId] = @purchaseStatusId
	WHERE [PurchaseId] = @purchaseId
/*
	SELECT	c.[Title]
					,	c.[IsPublished]
	FROM [dbo].[text_Chapter] AS c
	INNER JOIN [dbo].[purchase_Item] AS i ON i.[ChapterId] = c.[ChapterId]
	WHERE i.[PurchaseId] = @purchaseId*/
END